import {request} from './request';

/**
 * 状态码
 * @type {{SUCCESS: number}}
 */
export const status = {
  SUCCESS: 200
}

/**
 * 公共接口
 * @type {{upload: (function(*=): *), login: (function(*=): *), register: (function(*=): *)}}
 */
export const common = {
  /**
   * 登录
   * @param params
   * @returns {*}
   */
  login: params => request.post('/index/login', params),
  /**
   * 注册
   * @param params
   * @returns {*}
   */
  register: params => request.post('/index/register', params),
  /**
   * 上传
   * @param params
   * @returns {*}
   */
  upload: params => request.post('/Common/upload', params),
};

/**
 * 用户操作
 * @type {{updatePwd: (function(*=): *), find: (function(*=): *), updateStatus: (function(*=): *), findInfo: (function(*=): *), save: (function(*=): *), del: (function(*=): *), list: (function(*=): *)}}
 */
export const user = {
  /**
   * 列表
   * @param params
   * @returns {*}
   */
  list: params => request.post('/user/index', params),
  /**
   * 查找
   * @param params
   * @returns {*}
   */
  find: params => request.post('/user/index', params),
  /**
   * 保存
   * @param params
   * @returns {*}
   */
  save: params => request.post('/user/save', params),
  /**
   * 更新状态
   * @param params
   * @returns {*}
   */
  updateStatus: params => request.post('/user/updateStatus', params),
  /**
   * 更新密码
   * @param params
   * @returns {*}
   */
  updatePwd: params => request.post('/users/updatePwd', params),
  /**
   * 删除
   * @param params
   * @returns {*}
   */
  del: params => request.post('/user/del', params),
};

/**
 * 学生操作
 * @type {{add: (function(*=): *), list: (function(*): *)}}
 */
export const student = {
  /**
   * 列表
   * @param params
   * @returns {*}
   */
  list: params => request.post('/user/studentList', params),
  /**
   * 添加
   * @param params
   * @returns {*}
   */
  add: params => request.post('/user/addStudent', params),
};

/**
 * 广告位置
 * @type {{add: (function(*=): *), read: (function(*=): *), del: (function(*=): *), list: (function(*=): *)}}
 */
export const adPosition = {
  list: params => request.post('/AdPosition/index', params),
  add: params => request.post('/AdPosition/add', params),
  read: params => request.post('/AdPosition/read', params),
  del: params => request.post('/AdPosition/del', params),
};

/**
 * 广告管理
 * @type {{add: (function(*=): *), read: (function(*=): *), del: (function(*=): *), list: (function(*=): *)}}
 */
export const ad = {
  list: params => request.post('/Ad/index', params),
  add: params => request.post('/Ad/save', params),
  read: params => request.post('/Ad/read', params),
  del: params => request.post('/Ad/del', params),
};

/**
 * 书籍操作
 * @type {{add: (function(*=): *), find: (function(*=): *), del: (function(*=): *), list: (function(*=): *)}}
 */
export const book = {
  /**
   * 书籍列表
   * @param params
   * @returns {*}
   */
  list: params => request.post('/book/index', params),
  /**
   * 查找
   * @param params
   * @returns {*}
   */
  find: params => request.post('/book/findBook', params),
  /**
   * 添加书籍
   * @param params
   * @returns {*}
   */
  add: params => request.post('/book/add', params),
  /**
   * 删除书籍
   * @param params
   * @returns {*}
   */
  del: params => request.post('/book/del', params),
};

/**
 * 借阅操作
 * @type {{add: (function(*=): *), find: (function(*=): *), updateStatus: (function(*=): *), list: (function(*=): *)}}
 */
export const borrow = {
  /**
   * 列表
   * @param params
   * @returns {*}
   */
  list: params => request.post('/borrow/index', params),
  /**
   * 查找
   * @param params
   * @returns {*}
   */
  find: params => request.post('/borrow/findBorrowList', params),
  /**
   * 添加
   * @param params
   * @returns {*}
   */
  add: params => request.post('/borrow/add', params),
  /**
   * 更新状态
   * @param params
   * @returns {*}
   */
  updateStatus: params => request.post('/borrow/updateStatus', params),
};

/**
 * 统计数据
 * @type {{userDataCount: (function(*): *)}}
 */
export const statistics = {
  /**
   *
   * @param params
   * @returns {*}
   */
  userDataCount: params => request.get(`/statistics/user`),
}
